package com.ruoyi.web.controller.system;

import java.util.List;

import com.ruoyi.web.controller.demo.domain.SysUserWzx;
import com.ruoyi.web.controller.service.ISysUserWzxService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * wzx的基础用户Controller
 * 
 * @author ruoyi
 * @date 2022-12-20
 */
@Controller
@RequestMapping("/system/wzx")
public class SysUserWzxController extends BaseController
{
    private String prefix = "system/wzx";

    @Autowired
    private ISysUserWzxService sysUserWzxService;

    @RequiresPermissions("system:wzx:view")
    @GetMapping()
    public String wzx()
    {
        return prefix + "/wzx";
    }

    /**
     * 查询wzx的基础用户列表
     */
    @RequiresPermissions("system:wzx:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysUserWzx sysUserWzx)
    {
        startPage();
        List<SysUserWzx> list = sysUserWzxService.selectSysUserWzxList(sysUserWzx);
        return getDataTable(list);
    }

    /**
     * 导出wzx的基础用户列表
     */
    @RequiresPermissions("system:wzx:export")
    @Log(title = "wzx的基础用户", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysUserWzx sysUserWzx)
    {
        List<SysUserWzx> list = sysUserWzxService.selectSysUserWzxList(sysUserWzx);
        ExcelUtil<SysUserWzx> util = new ExcelUtil<SysUserWzx>(SysUserWzx.class);
        return util.exportExcel(list, "wzx的基础用户数据");
    }

    /**
     * 新增wzx的基础用户
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存wzx的基础用户
     */
    @RequiresPermissions("system:wzx:add")
    @Log(title = "wzx的基础用户", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysUserWzx sysUserWzx)
    {
        return toAjax(sysUserWzxService.insertSysUserWzx(sysUserWzx));
    }

    /**
     * 修改wzx的基础用户
     */
    @RequiresPermissions("system:wzx:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysUserWzx sysUserWzx = sysUserWzxService.selectSysUserWzxById(id);
        mmap.put("sysUserWzx", sysUserWzx);
        return prefix + "/edit";
    }

    /**
     * 修改保存wzx的基础用户
     */
    @RequiresPermissions("system:wzx:edit")
    @Log(title = "wzx的基础用户", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysUserWzx sysUserWzx)
    {
        return toAjax(sysUserWzxService.updateSysUserWzx(sysUserWzx));
    }

    /**
     * 删除wzx的基础用户
     */
    @RequiresPermissions("system:wzx:remove")
    @Log(title = "wzx的基础用户", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysUserWzxService.deleteSysUserWzxByIds(ids));
    }
}
